package
{
	import flash.display.Sprite;
	import flash.display.Stage;
	
	import manager.BarrierManager;
	import manager.BulletManager;
	import manager.KingManager;
	import manager.MonsterManager;
	import manager.TowerManager;
	
	import mx.core.FlexGlobals;

	/**
	 *游戏 
	 * @author SXT
	 */
	public class Game
	{
		private static var _instance:Game;
		private var _game:TD;
		private var _mtLayer:Sprite;
		private var _bulletLayer:Sprite;
		private var _gameStage:Stage;
		
		public var monsterManager:MonsterManager;
		public var barrierManager:BarrierManager;
		public var bulletManager:BulletManager;
		public var towerManager:TowerManager;
		
		public function Game(key:Key)
		{
			_mtLayer = new Sprite();
			_mtLayer.name = "怪物炮塔层";
			_bulletLayer = new Sprite();
			_bulletLayer.name = "子弹层";
		}
		/**
		 *子弹层 
		 * @return 
		 */		
		public function get bulletLayer():Sprite
		{
			return _bulletLayer;
		}

		public function set bulletLayer(value:Sprite):void
		{
			_bulletLayer = value;
		}

		public function get gameStage():Stage
		{
			return _gameStage;
		}

		public function set gameStage(value:Stage):void
		{
			_gameStage = value;
		}

		/**
		 *怪物和炮塔层 
		 */
		public function get mtLayer():Sprite
		{
			return _mtLayer;
		}

		public function get main():TD
		{
			return _game;
		}

		public function set main(value:TD):void
		{
			_game = value;
			gameStage.addChild(mtLayer);
			gameStage.addChild(bulletLayer);
		}

		public static function get instance():Game{
			if(_instance == null){
				_instance = new Game(new Key);
			}
			return _instance;
		}
		
		/**
		 *怪物管理器 
		 * @return 
		 */
		public function get monsterMag():MonsterManager{
			return _game["monsterManager"];
		}
		
		/**
		 *子弹管理器 
		 * @return 
		 */
		public function get bulletMag():BulletManager{
			return  _game["bulletManager"];
		}
		
		/**
		 *皇上管理器 
		 * @return 
		 */		
		public function get kingMag():KingManager{
			return  _game["kingManager"];
		}
	}
}

class Key{}